package cn.jiyun.mapper;

import cn.jiyun.pojo.Constractor;
import cn.jiyun.pojo.Project;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;


public interface ConstractorMapper {

    int add(Constractor constractor);

    List<Map> findAll(@Param("pageNum") int pageNum, @Param("pageSize") Integer pageSize, @Param("queryString") String queryString);

    @Select("select count(*) from constractor")
    Long getCount();

    @Update("UPDATE `constractor` SET `bname` = #{bname}, pid= #{pid} ,did=#{did}   WHERE `bid` = #{bid}")
    int update(Constractor constractoreloper);

    @Delete("delete from  constractor where bid=#{did} ")
    int delete(Integer did);

    @Select("select * from constractor where bid=#{did}")
    Constractor findById(Integer did);

    @Select("select * from project p where p.did=#{did} ")
    Project findByPro(Integer did);


    @Select("select * from project p where p.pid in (select p.pid from project p,constractor d where p.did=d.did and p.did =#{did} )")
    List<Project> findProjectList(Integer did);
    @Select("select * from project ")
    List<Project> findProjectList2();

    @Update("update project set cid = #{cid} where pid =#{pid}")
    void addpid( @Param("cid")Integer cid,@Param("pid") Integer pid);
}
